/*
 * @Descripttion: 退出
 * @version: 1.0
 * @Author: 自由如风
 * @Date: 2021-04-27 17:40:49
 * @LastEditors: 自由如风
 * @LastEditTime: 2021-04-28 08:12:50
 */
const DB = require('../../lib/DB')
module.exports = async function logout(ctx, next) {
    // 更新退出时间
    const user = await DB.models.user.findByPk(ctx.session.user.id)
    user.exit_time = Date.now();
    // 清空 user 
    ctx.session.user = null;
    await user.save();
    await next();
}